package com.czh.intelligentoj.judge.codesandbox;

import com.czh.intelligentoj.judge.codesandbox.model.ExecuteCodeRequest;
import com.czh.intelligentoj.judge.codesandbox.model.ExecuteCodeResponse;
import lombok.extern.slf4j.Slf4j;

/*
 * ClassName: CodeSandboxProxy
 * Package: com.czh.intelligentoj.judge
 * Description:
 *            对代码沙箱进行增强：在代码沙箱执行前后进行 请求和响应 的日志记录
 * @Author: CZH
 * @Create: 2025
 */


@Slf4j
public class CodeSandboxProxy implements CodeSandbox{

    private final CodeSandbox codeSandbox;
    /**
     *
     * @param codeSandbox
     */
    public CodeSandboxProxy(CodeSandbox codeSandbox) {
        this.codeSandbox = codeSandbox;
    }
    /**
     *
     * @param executeCodeRequest
     * @return
     */
    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        log.info("代码沙箱请求信息：" + executeCodeRequest.toString());
        ExecuteCodeResponse executeCodeResponse = codeSandbox.executeCode(executeCodeRequest);
        log.info("代码沙箱响应信息：" + executeCodeResponse.toString());
        return executeCodeResponse;
    }
}
